﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BDCS.BLL;
using BDCS.Model;


namespace UI
{
    public partial class AddBuildTypes : Form
    {
        #region 成员字段
        private BDCS.BLL.T_BuildTyppes bllBuildTypes;
        private DataSet dataSet;
        private BDCS.Model.T_BuildTyppes buildTypes; 
        #endregion
        #region 构造函数
        public AddBuildTypes()
        {
            InitializeComponent();
        } 
        #endregion

        #region 成员事件
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtBuildTypeName.Text.Trim()))
            {
                MessageBox.Show("请输入建筑大类名称！");
            }
            else
            {
                bllBuildTypes = new BDCS.BLL.T_BuildTyppes();
                dataSet = new DataSet();
                dataSet = bllBuildTypes.GetList("BTName=" + "'" + txtBuildTypeName.Text.Trim() + "'");
                if (dataSet.Tables[0].Rows.Count==0)
                {
                    buildTypes = new BDCS.Model.T_BuildTyppes();
                    buildTypes.BTName = txtBuildTypeName.Text.Trim();
                    buildTypes.BTypeDescribe = txtBuildTypeDescribe.Text.Trim();
                    if (bllBuildTypes.Add(buildTypes) != 0)
                    {
                        BDCS.Common.TreeViewState.IsChangedAttribute = true;
                        MessageBox.Show("添加成功！");
                    }
                    else
                    {
                        MessageBox.Show("添加失败，请重新添加！");
                    }
                }
                else
                {
                    MessageBox.Show("该内容已经存在，请重新输入！");
                }
            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.txtBuildTypeName.Text = string.Empty;
            this.txtBuildTypeDescribe.Text = string.Empty;
        } 
        #endregion

        private void AddBuildTypes_Load(object sender, EventArgs e)
        {

        }
    }
}
